package com.setting.deflinechartutils;

import android.content.Context;
import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.github.mikephil.charting.R;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;

import java.text.DecimalFormat;

public class PointDataView extends MarkerView
{
    private LinearLayout linearLayout;
    private TextView tvContent;
    private DecimalFormat format = new DecimalFormat("#.#");



    public PointDataView(Context context, int drawable, float textsize, int textcolor) {
        super(context, R.layout.layout_pointdataview);
        linearLayout = (LinearLayout) findViewById(R.id.ll_layout);
        linearLayout.setBackgroundResource(drawable);
        tvContent = (TextView) findViewById(R.id.tvContent);
        tvContent.setTextSize(textsize);
        tvContent.setTextColor(textcolor);
    }

    //显示的内容
    @Override
    public void refreshContent(Entry e, Highlight highlight) {
        tvContent.setText(format.format(e.getY()));
        super.refreshContent(e, highlight);
    }

    //标记相对于折线图的偏移量
    @Override
    public MPPointF getOffset() {
        return new MPPointF(-(getWidth() / 2), -(getHeight() + 12));
    }

}
